package com.shenmazong.controller;

import com.shenmazong.service.TbUserService;
import com.shenmazong.utils.ResultResponse;
import com.shenmazong.vo.AddUserVo;
import com.shenmazong.vo.LoginVo;
import com.shenmazong.vo.MobileVo;
import com.shenmazong.vo.ResetPassworVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 军哥
 * @version 1.0
 * @description: TODO
 * @date 2022/1/6 10:37
 */

@RestController
@Slf4j
@Api(description = "用户API接口")
public class TbUserController {

    @Autowired
    TbUserService tbUserService;

    @ApiOperation(value="买家用户登录", notes="根据用户名和密码进行登录", produces="application/json")
    @PostMapping(value = "/userLogin")
    public ResultResponse userLogin(@RequestBody LoginVo loginVo) {
        return tbUserService.userLogin(loginVo);
    }

    @ApiOperation(value="买家用户重置密码", notes="根据原密码对密码进行重置", produces="application/json")
    @PostMapping(value = "/userResetPassword")
    public ResultResponse userResetPassword(@RequestBody ResetPassworVo resetPassworVo) {
        return tbUserService.userResetPassword(resetPassworVo);
    }

    @ApiOperation(value="买家用户注册", notes="买家用户进行注册", produces="application/json")
    @PostMapping(value = "/addUser")
    public ResultResponse addUser(@RequestBody AddUserVo addUserVo) {
        return tbUserService.addUser(addUserVo);
    }

    @ApiOperation(value="发送验证码", notes="根据手机号发送验证码", produces="application/json")
    @PostMapping(value = "/sendCode")
    public ResultResponse sendCode(@RequestBody MobileVo mobileVo) {
        return tbUserService.sendCode(mobileVo);
    }
}
